home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / New System Software Extensions / Macintosh Drag and Drop 1.1.1 / Interfaces / Drag.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-22  |  10.1 KB  |  389 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Drag.h
  3.  
  4.     Contains:    C Interface to the Drag Manager
  5.  
  6.     Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. */
  9.  
  10. #ifndef __DRAG__
  11. #define __DRAG__
  12.  
  13. #ifndef __APPLEEVENTS__
  14. #include <AppleEvents.h>
  15. #endif
  16.  
  17. #ifndef __TEXTEDIT__
  18. #include <TextEdit.h>
  19. #endif
  20.  
  21.  
  22. /* Gestalt Selector and Response Constants (will move to GestaltEqu.h) */
  23.  
  24. #define    gestaltDragMgrAttr            'drag'        // Drag Manager attributes
  25. #define    gestaltDragMgrPresent        0            // Drag Manager is present
  26. #define gestaltDragMgrFloatingWind    1            // Drag Manager supports floating windows
  27. #define gestaltPPCDragLibPresent    2            // Drag Manager PPC DragLib is present
  28.  
  29. #define    gestaltTEAttr                'teat'        // TextEdit attributes
  30. #define gestaltTEHasGetHiliteRgn    0            // TextEdit has TEGetHiliteRgn
  31.  
  32.  
  33. /* Flavor Flags */
  34.  
  35. enum {
  36.     flavorSenderOnly                = 0x00000001L,    // flavor is available to sender only
  37.     flavorSenderTranslated            = 0x00000002L,    // flavor is translated by sender
  38.     flavorNotSaved                    = 0x00000004L,    // flavor should not be saved
  39.     flavorSystemTranslated            = 0x00000100L    // flavor is translated by system
  40. };
  41.  
  42. typedef unsigned long FlavorFlags;
  43.  
  44.  
  45. /* Drag Attributes */
  46.  
  47. enum {
  48.     dragHasLeftSenderWindow            = 0x00000001L,    // drag has left the source window since TrackDrag
  49.     dragInsideSenderApplication        = 0x00000002L,    // drag is occurring within the sender application
  50.     dragInsideSenderWindow            = 0x00000004L    // drag is occurring within the sender window
  51. };
  52.  
  53. typedef unsigned long DragAttributes;
  54.  
  55.  
  56. /* Special Flavor Types */
  57.  
  58. #define flavorTypeHFS                'hfs '        // flavor type for HFS data
  59. #define flavorTypePromiseHFS        'phfs'        // flavor type for promised HFS data
  60. #define flavorTypeDirectory            'diry'        // flavor type for AOCE directories
  61.  
  62.  
  63. /* Drag Tracking Handler Messages */
  64.  
  65. enum {
  66.     dragTrackingEnterHandler        = 1,        // drag has entered handler
  67.     dragTrackingEnterWindow            = 2,        // drag has entered window
  68.     dragTrackingInWindow            = 3,        // drag is moving within window
  69.     dragTrackingLeaveWindow            = 4,        // drag has exited window
  70.     dragTrackingLeaveHandler        = 5            // drag has exited handler
  71. };
  72.  
  73. typedef short DragTrackingMessage;
  74.  
  75.  
  76. /* Drag Drawing Procedure Messages */
  77.  
  78. enum {
  79.     dragRegionBegin                    = 1,        // initialize drawing
  80.     dragRegionDraw                    = 2,        // draw drag feedback
  81.     dragRegionHide                    = 3,        // hide drag feedback
  82.     dragRegionIdle                    = 4,        // drag feedback idle time
  83.     dragRegionEnd                    = 5            // end of drawing
  84. };
  85.  
  86. typedef short DragRegionMessage;
  87.  
  88.  
  89. /* Zoom Acceleration */
  90.  
  91. enum {
  92.     zoomNoAcceleration                = 0,        // use linear interpolation
  93.     zoomAccelerate                    = 1,        // ramp up step size
  94.     zoomDecelerate                    = 2            // ramp down step size
  95. };
  96.  
  97. typedef short ZoomAcceleration;
  98.  
  99.  
  100. /* Drag Manager Data Types */
  101.  
  102. typedef unsigned long DragReference;
  103. typedef unsigned long ItemReference;
  104.  
  105. typedef ResType FlavorType;
  106.  
  107.  
  108. /* Result Codes - (will move to Errors.h) */
  109.  
  110. enum {
  111.     badDragRefErr                = -1850,    // unknown drag reference
  112.     badDragItemErr                = -1851,    // unknown drag item reference
  113.     badDragFlavorErr            = -1852,    // unknown flavor type
  114.     duplicateFlavorErr            = -1853,    // flavor type already exists
  115.     cantGetFlavorErr            = -1854,    // error while trying to get flavor data
  116.     duplicateHandlerErr            = -1855,    // handler already exists
  117.     handlerNotFoundErr            = -1856,    // handler not found
  118.     dragNotAcceptedErr            = -1857        // drag was not accepted by receiver
  119. };
  120.  
  121. /* HFS Flavors */
  122.  
  123. struct HFSFlavor {
  124.     OSType            fileType;                    // file type
  125.     OSType            fileCreator;                // file creator
  126.     unsigned short    fdFlags;                    // Finder flags
  127.     FSSpec            fileSpec;                    // file system specification
  128. };
  129. typedef struct HFSFlavor HFSFlavor;
  130.  
  131. struct PromiseHFSFlavor {
  132.     OSType            fileType;                    // file type
  133.     OSType            fileCreator;                // file creator
  134.     unsigned short    fdFlags;                    // Finder flags
  135.     FlavorType        promisedFlavor;                // promised flavor containing an FSSpec
  136. };
  137. typedef struct PromiseHFSFlavor PromiseHFSFlavor;
  138.  
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142.  
  143. /* Application-Defined Drag Handler Routines */
  144.  
  145. typedef pascal OSErr (*DragTrackingHandler) (DragTrackingMessage message, WindowPtr theWindow,
  146.                                              void *handlerRefCon, DragReference theDragRef);
  147.  
  148. typedef pascal OSErr (*DragReceiveHandler) (WindowPtr theWindow, void *handlerRefCon,
  149.                                             DragReference theDragRef);
  150.  
  151.  
  152. /* Application-Defined Routines */
  153.  
  154. typedef pascal OSErr (*DragSendDataProc) (FlavorType theType, void *dragSendRefCon,
  155.                                           ItemReference theItemRef, DragReference theDragRef);
  156.  
  157. typedef pascal OSErr (*DragInputProc) (Point *mouse, short *modifiers, void *dragInputRefCon,
  158.                                        DragReference theDragRef);
  159.  
  160. typedef pascal OSErr (*DragDrawingProc) (DragRegionMessage message,
  161.                                          RgnHandle showRegion, Point showOrigin,
  162.                                          RgnHandle hideRegion, Point hideOrigin,
  163.                                          void *dragDrawingRefCon, DragReference theDragRef);
  164.  
  165.  
  166. /*
  167.  *    Drag Manager Routines
  168.  */
  169.  
  170.  
  171. /* Installing and Removing Drag Handlers */
  172.  
  173. pascal OSErr InstallTrackingHandler
  174.                                 (DragTrackingHandler trackingHandler,
  175.                                  WindowPtr theWindow,
  176.                                  void *handlerRefCon)
  177.     = { 0x7001, 0xABED };
  178.  
  179. pascal OSErr InstallReceiveHandler
  180.                                 (DragReceiveHandler receiveHandler,
  181.                                  WindowPtr theWindow,
  182.                                  void *handlerRefCon)
  183.     = { 0x7002, 0xABED };
  184.  
  185. pascal OSErr RemoveTrackingHandler
  186.                                 (DragTrackingHandler trackingHandler,
  187.                                  WindowPtr theWindow)
  188.     = { 0x7003, 0xABED };
  189.  
  190. pascal OSErr RemoveReceiveHandler
  191.                                 (DragReceiveHandler receiveHandler,
  192.                                  WindowPtr theWindow)
  193.     = { 0x7004, 0xABED };
  194.  
  195.  
  196. /* Creating and Disposing Drag References */
  197.  
  198. pascal OSErr NewDrag            (DragReference *theDragRef)
  199.     = { 0x7005, 0xABED };
  200.  
  201. pascal OSErr DisposeDrag        (DragReference theDragRef)
  202.     = { 0x7006, 0xABED };
  203.  
  204.  
  205. /* Adding Drag Item Flavors */
  206.  
  207. pascal OSErr AddDragItemFlavor    (DragReference theDragRef,
  208.                                  ItemReference theItemRef,
  209.                                  FlavorType theType,
  210.                                  void *dataPtr,
  211.                                  Size dataSize,
  212.                                  FlavorFlags theFlags)
  213.     = { 0x7007, 0xABED };
  214.  
  215. pascal OSErr SetDragItemFlavorData
  216.                                 (DragReference theDragRef,
  217.                                  ItemReference theItemRef,
  218.                                  FlavorType theType,
  219.                                  const void *dataPtr,
  220.                                  Size dataSize,
  221.                                  unsigned long dataOffset)
  222.     = { 0x7009, 0xABED };
  223.  
  224.  
  225. /* Providing Drag Callback Procedures */
  226.  
  227. pascal OSErr SetDragSendProc    (DragReference theDragRef,
  228.                                  DragSendDataProc sendProc,
  229.                                  void *dragSendRefCon)
  230.     = { 0x700A, 0xABED };
  231.  
  232. pascal OSErr SetDragInputProc    (DragReference theDragRef,
  233.                                  DragInputProc inputProc,
  234.                                  void *dragInputRefCon)
  235.     = { 0x700B, 0xABED };
  236.  
  237. pascal OSErr SetDragDrawingProc    (DragReference theDragRef,
  238.                                  DragDrawingProc drawingProc,
  239.                                  void *dragDrawingRefCon)
  240.     = { 0x700C, 0xABED };
  241.  
  242.  
  243. /* Performing a Drag */
  244.  
  245. pascal OSErr TrackDrag            (DragReference theDragRef,
  246.                                  const EventRecord *theEvent,
  247.                                  RgnHandle theRegion)
  248.     = { 0x700D, 0xABED };
  249.  
  250.  
  251. /* Getting Drag Item Information */
  252.  
  253. pascal OSErr CountDragItems        (DragReference theDragRef,
  254.                                  unsigned short *numItems)
  255.     = { 0x700E, 0xABED };
  256.  
  257. pascal OSErr GetDragItemReferenceNumber
  258.                                 (DragReference theDragRef,
  259.                                  unsigned short index,
  260.                                  ItemReference *theItemRef)
  261.     = { 0x700F, 0xABED };
  262.  
  263. pascal OSErr CountDragItemFlavors
  264.                                 (DragReference theDragRef,
  265.                                  ItemReference theItemRef,
  266.                                  unsigned short *numFlavors)
  267.     = { 0x7010, 0xABED };
  268.  
  269. pascal OSErr GetFlavorType        (DragReference theDragRef,
  270.                                  ItemReference theItemRef,
  271.                                  unsigned short index,
  272.                                  FlavorType *theType)
  273.     = { 0x7011, 0xABED };
  274.  
  275. pascal OSErr GetFlavorFlags        (DragReference theDragRef,
  276.                                  ItemReference theItemRef,
  277.                                  FlavorType theType,
  278.                                  FlavorFlags *theFlags)
  279.     = { 0x7012, 0xABED };
  280.  
  281. pascal OSErr GetFlavorDataSize    (DragReference theDragRef,
  282.                                  ItemReference theItemRef,
  283.                                  FlavorType theType,
  284.                                  Size *dataSize)
  285.     = { 0x7013, 0xABED };
  286.  
  287. pascal OSErr GetFlavorData        (DragReference theDragRef,
  288.                                  ItemReference theItemRef,
  289.                                  FlavorType theType,
  290.                                  void *dataPtr,
  291.                                  Size *dataSize,
  292.                                  unsigned long dataOffset)
  293.     = { 0x7014, 0xABED };
  294.  
  295. pascal OSErr GetDragItemBounds    (DragReference theDragRef,
  296.                                  ItemReference theItemRef,
  297.                                  Rect *itemBounds)
  298.     = { 0x7015, 0xABED };
  299.  
  300. pascal OSErr SetDragItemBounds    (DragReference theDragRef,
  301.                                  ItemReference theItemRef,
  302.                                  const Rect *itemBounds)
  303.     = { 0x7016, 0xABED };
  304.  
  305. pascal OSErr GetDropLocation    (DragReference theDragRef,
  306.                                  AEDesc *dropLocation)
  307.     = { 0x7017, 0xABED };
  308.  
  309. pascal OSErr SetDropLocation    (DragReference theDragRef,
  310.                                  const AEDesc *dropLocation)
  311.     = { 0x7018, 0xABED };
  312.  
  313.  
  314. /* Getting Information About a Drag */
  315.  
  316. pascal OSErr GetDragAttributes    (DragReference theDragRef,
  317.                                  DragAttributes *flags)
  318.     = { 0x7019, 0xABED };
  319.  
  320. pascal OSErr GetDragMouse        (DragReference theDragRef,
  321.                                  Point *mouse,
  322.                                  Point *pinnedMouse)
  323.     = { 0x701A, 0xABED };
  324.  
  325. pascal OSErr SetDragMouse        (DragReference theDragRef,
  326.                                  Point pinnedMouse)
  327.     = { 0x701B, 0xABED };
  328.  
  329. pascal OSErr GetDragOrigin        (DragReference theDragRef,
  330.                                  Point *initialMouse)
  331.     = { 0x701C, 0xABED };
  332.  
  333. pascal OSErr GetDragModifiers    (DragReference theDragRef,
  334.                                  short *modifiers,
  335.                                  short *mouseDownModifiers,
  336.                                  short *mouseUpModifiers)
  337.     = { 0x701D, 0xABED };
  338.  
  339.  
  340. /* Drag Highlighting */
  341.  
  342. pascal OSErr ShowDragHilite        (DragReference theDragRef,
  343.                                  RgnHandle hiliteFrame,
  344.                                  Boolean inside)
  345.     = { 0x701E, 0xABED };
  346.  
  347. pascal OSErr HideDragHilite        (DragReference theDragRef)
  348.     = { 0x701F, 0xABED };
  349.  
  350. pascal OSErr DragPreScroll        (DragReference theDragRef,
  351.                                  short dH,
  352.                                  short dV)
  353.     = { 0x7020, 0xABED };
  354.  
  355. pascal OSErr DragPostScroll        (DragReference theDragRef)
  356.     = { 0x7021, 0xABED };
  357.  
  358. pascal OSErr UpdateDragHilite    (DragReference theDragRef,
  359.                                  RgnHandle updateRgn)
  360.     = { 0x7022, 0xABED };
  361.  
  362.  
  363. /* Drag Manager Utilities */
  364.  
  365. pascal Boolean WaitMouseMoved    (Point initialMouse)
  366.     = { 0x7023, 0xABED };
  367.  
  368. pascal OSErr ZoomRects            (const Rect *fromRect,
  369.                                  const Rect *toRect,
  370.                                  short zoomSteps,
  371.                                  ZoomAcceleration acceleration)
  372.     = { 0x7024, 0xABED };
  373.  
  374. pascal OSErr ZoomRegion            (RgnHandle region,
  375.                                  Point zoomDistance,
  376.                                  short zoomSteps,
  377.                                  ZoomAcceleration acceleration)
  378.     = { 0x7025, 0xABED };
  379.  
  380. // Will move to TextEdit.h
  381. pascal OSErr TEGetHiliteRgn        (RgnHandle region, TEHandle hTE)
  382.     = { 0x3F3C, 0x000F, 0xA83D };
  383.  
  384. #ifdef __cplusplus
  385. }
  386. #endif
  387.  
  388. #endif
  389.